<!DOCTYPE html>
<html lang="en">

<head>
  <meta charset="UTF-8">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <title>Document</title>
  <script src="https://cdn.jsdelivr.net/npm/vue/dist/vue.js"></script>
</head>

<body>

  <div id="app">

    <component :is="getCurrent"></component>

    <div>
      <button @click="handleClick(tab.id)" v-for="tab in tabs">{{tab.txt}}</button>
    </div>

    <hr>

    <table>
      <tr is="tab-position"></tr>
    </table>
  </div>

  <script type="text/template" id="tmp">
    <div>职位列表</div>
  </script>

  <script>

    Vue.component('tab-position', {
      template: `#tmp`
    })

    Vue.component('tab-search', {
      template: `<div>搜索页面</div>`
    })

    Vue.component('tab-my', {
      template: `<div>我的页面</div>`
    })


    var vm = new Vue({
      el: "#app",
      data: {
        current: 'position',
        tabs: [{ id: 'position', txt: '职位' }, { id: 'search', txt: '搜索' }, { id: 'my', txt: '我的' }]
      },
      methods: {
        handleClick(item) {
          this.current = item;
        }
      },
      computed: {
        getCurrent() {
          return 'tab-' + this.current;
        }
      }
    })
  </script>
</body>

</html>